import * as echarts from 'echarts';
Vue.prototype.$echarts = echarts;
import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import vuetify from './plugins/vuetify';

// icon 图标本地化 
import 'mdi/css/materialdesignicons.css';
import '@mdi/font/css/materialdesignicons.css';
import 'material-design-icons-iconfont/dist/material-design-icons.css';
import './assets/css/iconfont.css';
// ZHJ
import {
	frameInRoutes
} from './router/routers.js';
//侧边栏
import {
	menuAside
} from '@/menu/index.js';
import {
	service,
	request,
	requestWithNotTimeOut
} from './api/service.js';
// message
import Message from './components/Message/index.js';
//message信息提示
Vue.prototype.$message = Message;
//阻止启动生产消息，常用作指令。
Vue.config.productionTip = false;
// 当前的 baseUrl
Vue.prototype.$baseUrl = process.env.BASE_URL;
//请求头包含请求token
Vue.prototype.$httpRequest = request;
//请求头不包含请求token
Vue.prototype.$httpService = service;
//请求头包含请求token,但不包含请求头
Vue.prototype.$httpRequestWithNotTimeOut = requestWithNotTimeOut;
//将echarts注册成Vue的全局属性
Vue.prototype.$echarts = echarts; 
Vue.filter('dateFormat', function(originVal) {
	if (originVal == null) {
		return '';
	}
	const dt = new Date(originVal);
	const y = dt.getFullYear();
	const m = (dt.getMonth() + 1 + '').padStart(2, '0');
	const d = (dt.getDate() + '').padStart(2, '0');
	return `${y}-${m}-${d}`;
});
Vue.filter('dateFormatHHMMSS', function(originVal) {
	if (originVal == null) {
		return '';
	}
	const dt = new Date(originVal);
	const y = dt.getFullYear();
	const m = (dt.getMonth() + 1 + '').padStart(2, '0');
	const d = (dt.getDate() + '').padStart(2, '0');
	const hh = (dt.getHours() + '').padStart(2, '0');
	const mm = (dt.getMinutes() + '').padStart(2, '0');
	const ss = (dt.getSeconds() + '').padStart(2, '0');
	return `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
});
//zhj
new Vue({
	
	router,
	store,
	vuetify,
	render: h => h(App),
	created() {
		// 处理路由 得到每一级的路由设置
		this.$store.commit('admin/page/init', frameInRoutes);
		this.$store.commit('admin/search/init', menuAside);
	},
	mounted() {
		this.$store.dispatch('admin/account/load');
		// 初始化全屏监听
		this.$store.dispatch('admin/fullscreen/listen');
		this.$store.commit('admin/ua/get');
	},
}).$mount('#app');
